<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:t="http://myfaces.apache.org/tomahawk">

	<ui:composition template="/template/pPrincipal.xhtml">

		<ui:define name="head">
			<title>BBVAITrade</title>
		</ui:define>

		<ui:define name="titulopagina">
			<p:toolbar>
				<p:toolbarGroup align="left" style="height: 20px;">
					<h:outputText value="MANTENIMIENTO CLASE - ARBOL CLASES"
						styleClass="textoTituloPagina" />
				</p:toolbarGroup>
			</p:toolbar>
		</ui:define>

		<ui:define name="bodyarea">
			<style type="text/css">
				.styleArbolClaseFIA {
					width: 350px;
				}
			</style>
			<p:messages id="growl" >
				<p:effect type="blind" event="load" delay="3000"/>
			</p:messages>
			<f:event type="preRenderView" listener="#{paramArbolClaseController.onPageLoad}"/>
			<p:accordionPanel multiple="true" activeIndex="0,1" id="idContentMain">
				<p:tab title="Clases">
					<h:panelGrid columns="2" style="margin-top: -30px">
						<p:spacer width="50" height="0" ></p:spacer>
						<p:spacer width="400" height="0" ></p:spacer>
						
						<h:outputText value="Tipo:" styleClass="texto" />
						<p:selectOneMenu value="#{paramArbolClaseController.selectedImpExpClaseFia}">
				            <f:selectItem itemLabel="-- Seleccionar --" itemValue="-1" />
				            <f:selectItem itemLabel="Todo" itemValue="T" />
				            <f:selectItem itemLabel="I" itemValue="I" />
						    <f:selectItem itemLabel="E" itemValue="E" />
						    <f:selectItem itemLabel="" itemValue="" />
				            <p:ajax event="change" listener="#{paramArbolClaseController.cargarListDataClaseFIA}"
				            	update=":formPrincipal:growl,:formPrincipal:idContentMain:idListDataClaseFIA"/>
				        </p:selectOneMenu>
					</h:panelGrid>
					<h:panelGrid columns="1">
						<p:spacer width="550" height="0" ></p:spacer>
						<p:dataTable value="#{paramArbolClaseController.listDataClaseFIA}" var="fila"
							paginator="true" rows="10" id="idListDataClaseFIA" editable="true">
							
							<p:ajax event="rowEdit" listener="#{paramArbolClaseController.onEditClase}" update=":formPrincipal:growl"/>
							
							<p:column styleClass="columnCenter">
								<f:facet name="header">
									<h:outputText value="Id" />
								</f:facet>
								<h:outputText value="#{fila.idClaseFia}" />
							</p:column>
							<p:column styleClass="columnCenter">
								<f:facet name="header">
									<h:outputText value="Cod. Clase" />
								</f:facet>
								<h:outputText value="#{fila.codClaseFia}" />
							</p:column>
							<p:column headerText="I/E">
					            <p:cellEditor>  
					                <f:facet name="output">  
					                    <h:outputText value="#{fila.indImpoExpo}"/>  
					                </f:facet>  
					                <f:facet name="input">
					                	<h:selectOneMenu value="#{fila.indImpoExpo}">
					                		<f:selectItem itemLabel="" itemValue="" />
								            <f:selectItem itemLabel="I" itemValue="I" />
								            <f:selectItem itemLabel="E" itemValue="E" />
								        </h:selectOneMenu>
					                </f:facet>  
					            </p:cellEditor>  
					        </p:column>
					        <p:column styleClass="columnCenter">
								<f:facet name="header">
									<h:outputText value="Descripción" />
								</f:facet>
								<h:outputText value="#{fila.descripcionSistema}" />
							</p:column>
							<p:column styleClass="columnCenter">
								<f:facet name="header">
									<h:outputText value="Estado" />
								</f:facet>
								<h:outputText value="#{fila.codSituacion}" />
							</p:column>
							<p:column style="width:9%">
					            <p:rowEditor />
					        </p:column>
						</p:dataTable>
					</h:panelGrid>
				</p:tab>
				<p:tab title="Arbol Clases">
					<h:panelGrid columns="2" style="margin-top: -30px">
						<p:spacer width="50" height="0" ></p:spacer>
						<p:spacer width="400" height="0" ></p:spacer>
						
						<h:outputText value="Tipo:" styleClass="texto" />
						<p:selectOneMenu value="#{paramArbolClaseController.selectedImpExpArbolClase}">
				            <f:selectItem itemLabel="-- Seleccionar --" itemValue="-1" />
				            <f:selectItem itemLabel="I" itemValue="I" />
						    <f:selectItem itemLabel="E" itemValue="E" />
				            <p:ajax event="change" listener="#{paramArbolClaseController.cargarListDataArbolFIA}" 
				            	update=":formPrincipal:growl,:formPrincipal:idContentMain:idDataArbol,:idModalManArbolClases,:formPrincipal:idContentMain:idGroupButtons"/>
				        </p:selectOneMenu>
					</h:panelGrid>
					<h:panelGrid columns="1" id="idDataArbol">
						<p:spacer width="550" height="0" ></p:spacer>
						<p:tree value="#{paramArbolClaseController.arbolClaseFIA}" var="node" 
								dynamic="true" cache="false" 
					            selectionMode="single"
					            selection="#{paramArbolClaseController.selectedNodeArbolClaseFIA}"
					            styleClass="styleArbolClaseFIA">
					        <p:ajax event="select" update=":formPrincipal:idContentMain:idGroupButtons" listener="#{paramArbolClaseController.onNodeSelect}" />
					        <p:treeNode>
					            <h:outputText value="#{node.descripcion}" />
					        </p:treeNode>
					    </p:tree>
					</h:panelGrid>
					<h:panelGrid columns="3" id="idGroupButtons">
						<p:commandButton value="Nuevo" actionListener="#{paramArbolClaseController.initModalNuevoNodo}" oncomplete="popNewUpdateArbolClases.show()" 
							update=":formPrincipal:growl,:newUpdateArbolClases,:idModalManArbolClases:idlistCheckClaseFIA,:idModalManArbolClases:idNodeValDescripcion"
							 rendered="#{paramArbolClaseController.showButtonNew}"/>
						<p:commandButton value="Eliminar" onclick="confirmationDetele.show()" rendered="#{paramArbolClaseController.showButtons}"/>
						<p:commandButton value="Modificar" actionListener="#{paramArbolClaseController.initModalActualizarNodo}" oncomplete="popNewUpdateArbolClases.show()" 
							update=":formPrincipal:growl,:newUpdateArbolClases,:idModalManArbolClases:idlistCheckClaseFIA,:idModalManArbolClases:idNodeValDescripcion"
							rendered="#{paramArbolClaseController.showButtons}"/>
					</h:panelGrid>
				</p:tab>
			</p:accordionPanel>
			<p:confirmDialog id="confirmDeleteDialog" message="¿Está seguro de eliminar el nodo?"
                header="Eliminar" severity="alert" widgetVar="confirmationDetele">
		        <p:commandButton id="confirmDetele" value="Si" oncomplete="confirmationDetele.hide()" update=":formPrincipal:growl,:formPrincipal:idContentMain:idDataArbol"
		        	actionListener="#{paramArbolClaseController.deleteNodeArbolClaseFIA}"/>
		        <p:commandButton id="decline" value="No" onclick="confirmationDetele.hide()" type="button" />
		    </p:confirmDialog>
		</ui:define>
		<ui:define name="extraarea">
			<ui:include src="/pages/parametria/include/popNewUpdateArbolClases.xhtml" />
		</ui:define>
	</ui:composition>
</jsp:root>
